import validateMap from '@/utils/validate'

const customFormRules = {
  booker: [
    {
      validator: (
        rule: any,
        value: string,
        callback: (arg0: Error | undefined) => any
      ) => {
        validateMap.$realPersonName(value, callback)
      },
      trigger: 'blur'
    }
  ],
  tel: [
    {
      // 自定义验证函数，见上说明
      validator: (rule: any, value: string, callback: any) => {
        // 上面有说，返回true表示校验通过，返回false表示不通过
        // uni.$u.test.mobile()就是返回true或者false的
        return uni.$u.test.mobile(value)
      },
      message: '手机号码不正确',
      // 触发器可以同时用blur和change
      trigger: ['change', 'blur']
    }
  ],
  remarks: [
    {
      validator: (
        rule: any,
        value: string | any[],
        callback: (arg0: Error | undefined) => any
      ) => {
        validateMap.$validLength(value, callback, 20)
      },
      trigger: ['blur', 'change']
    }
  ],
  arrivalstime: [
    {
      required: true,
      message: '请选择预抵达时间',
      // blur和change事件触发检验
      trigger: ['blur', 'change']
    }
  ]
  // num: [
  //   {
  //     required: true,
  //     message: '请选择房间数量',
  //     // blur和change事件触发检验
  //     trigger: ['blur', 'change'],
  //   },
  // ],
}
export default customFormRules
